package com.spring.aop.interceptor;

import com.spring.aop.Advisor;
import com.spring.aop.InterceptorChain;

import java.lang.reflect.Method;

public class AfterThrowingInterceptor extends Interceptor {
	public AfterThrowingInterceptor(Advisor advisor) {
		super(advisor);
	}
	
	@Override
	public Object invoke(InterceptorChain chain, Object targetObject, Method targetMethod, Object[] args) throws Throwable {
		try {
			return chain.proceed(targetObject, targetMethod, args);
		} catch (Exception e) {
			// 异常通知在这里
			advisor.afterThrowing();
			throw e;
		}
	}
}
